package com.ruoyi.goods.service.impl;

import java.util.Collection;
import java.util.List;

import com.ruoyi.common.exception.ServiceException;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.goods.mapper.StoreMapper;
import com.ruoyi.goods.domain.Store;
import com.ruoyi.goods.service.IStoreService;

/**
 * 仓库信息Service业务层处理
 *
 * @author yeqi
 * @date 2022-11-27
 */
@Service
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements IStoreService {

    /**
     * 查询仓库信息列表
     *
     * @param store 仓库信息
     * @return 仓库信息
     */
    @Override
    public List<Store> selectStoreList(Store store) {
        return getBaseMapper().selectStoreList(store);
    }

    @Override
    public boolean deleteBach(Long[] ids) {
        for (Long id : ids) {
            int count = getBaseMapper().selectGoodsById(id);
            if (count != 0){
                throw new ServiceException("该仓库下还有商品不能删除");
            }
        }
        return getBaseMapper().chageStatus(ids);
    }

    @Override
    public boolean save(Store entity) {
        // 为添加增加状态
        entity.setState(0);
        return super.save(entity);
    }


}
